package io.renren.modules.app.controller;

import io.renren.common.exception.RRException;
import io.renren.common.utils.R;
import io.renren.modules.bs.entity.BsDepartmentEntity;
import io.renren.modules.bs.service.BsDepartmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/app/department")
@Api(value = "科室接口",tags="科室接口")
public class AppDepartmentController {

    @Autowired
    private BsDepartmentService departmentService;

    @GetMapping("listByHospitalId")
    @ApiOperation("根据医院获得科室列表")
    public R listByHospitalId(Long hospitalId){

        if(hospitalId == null){
            throw new RRException("医院ID不能为空");
        }
        List<Long> hospitalList = new ArrayList<>();
        hospitalList.add(hospitalId);
        List<BsDepartmentEntity> departmentEntities = departmentService.getListByHospitalIds(hospitalList);
        return R.ok().put(departmentEntities);
    }
}
